package 牛客小白月赛94;

import java.util.Scanner;

public class A小苯的九宫格 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a[] = new int[10];
		for(int i = 1; i <= 9; i ++ ) {
			a[i] = sc.nextInt();
		}
		String s = sc.next();
		String ret = "";
		
		for(int i = 0; i < s.length(); i ++ ) {
			ret = ret + String.valueOf(a[s.charAt(i) - '0']);
		}
		System.out.print(ret);
	}
}
